/*
 * This is Melet, a salary slip designer. Feed it with data regarding to salary payment, prepare it for print through the graphical presentation, and you have it done.
 * Copyright (C) 2014, AFDiaX
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * This program is based on UMLet, a Free UML Tool for Fast UML Diagrams.
 * To contact the authors of UMLet visit https://code.google.com/p/umlet/people/list
 * To contact the authors of Melet visit https://gna.org/users/gabocze
 */
package com.baselet.element.old.activity;

import java.awt.Graphics2D;

import com.baselet.diagram.DiagramHandler;

public class Activity extends Element {

	protected Label label;

	public Activity(DiagramHandler handler, String label, Graphics2D g, String id) {
		super(handler, g, (int) (Const.PAD * handler.getZoomFactor()), id == null ? label : id);
		this.label = new Label(handler, label, g, (int) (5 * getZoom()));
	}

	@Override
	protected int getHeight() {
		return label.getHeight() + label.getPadding() * 2 + super.getHeight();
	}

	@Override
	protected int getLeftWidth() {
		return label.getLeftWidth() + label.getPadding() + super.getLeftWidth();
	}

	@Override
	protected int getRightWidth() {
		return label.getRightWidth() + label.getPadding() + super.getRightWidth();
	}

	@Override
	public void setY(int y) {
		super.setY(y);
		label.setY(y);
	}

	@Override
	public void setX(int x) {
		super.setX(x);
		label.setX(x);
	}

	@Override
	public void paint() {
		int h = getHeight();
		label.paint();
		getGraphics().drawRoundRect(getPosition().x - label.getLeftWidth() - label.getPadding(),
				getPosition().y - h / 2, label.getWidth() + label.getPadding() * 2, h, (int) (20 * getZoom()), (int) (20 * getZoom()));
	}
}
